﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Progetto.Beans
{
    public class MyCalendar
    {
        private string _name;
        private string _description;
        private string _color;
        private static string _emptyString = String.Empty;
        private Dictionary<string, Event> _events = new Dictionary<string, Event>();


        public MyCalendar(string name)
        {
            if (name == null)
                throw new ArgumentNullException();
            _name = name;
            _description = _emptyString;
            _color = _emptyString;
        }

        public MyCalendar(string name, string description, string color) : this(name)
        {
            if (color == null || description == null)
                throw new ArgumentNullException();
            _description = description;
            _color = color;
        }

        public MyCalendar(string name, string description, string color, List<Event> events)
            : this(name, description, color)
        {
            if (events == null)
                throw new ArgumentNullException();
            foreach (Event e in events)
            {
                _events.Add(e.Name, e);
            }
        }

        public MyCalendar(XmlElement calendar) 
        {
            
        }

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        public string Color
        {
            get { return _color; }
            set { _color = value; }
        }

        public Dictionary<string, Event> Events
        {
            get { return _events; }
            set { _events = value; }
        }

        public void AddEvent(Event e)
        {
            if (e == null)
                throw new ArgumentNullException();
            _events.Add(e.Name, e);
        }

        public Dictionary<string, Event> GetPrivateEvents()
        {
            Dictionary<string, Event> privateEvents = new Dictionary<string,Event>();
            foreach (Event e in _events.Values) 
            {
                if (e.IsPublic == false)
                    privateEvents.Add(e.Name, e);
            }
            return privateEvents;
        }

    }
}
